package cn.wolfcode.wolf2w.service.impl;

import cn.wolfcode.wolf2w.domain.SpotsDetails;
import cn.wolfcode.wolf2w.repository.SpotsDetailsRepository;
import cn.wolfcode.wolf2w.service.ISpotsDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SpotsDetailsServiceImpl implements ISpotsDetailsService {



    @Autowired
    private SpotsDetailsRepository spotsDetailsRepository;


    @Autowired
    private MongoTemplate template;

    @Override
    public void insert(SpotsDetails spotsDetails) {
        spotsDetailsRepository.insert(spotsDetails);
        spotsDetails.setId(null);
    }

    @Override
    public void delete(String id) {
        spotsDetailsRepository.deleteById(id);
    }

    @Override
    public void update(SpotsDetails spotsDetails) {
        spotsDetailsRepository.save(spotsDetails);
    }

    @Override
    public SpotsDetails selectOne(String id) {
        SpotsDetails spotsDetails = spotsDetailsRepository.findById(id).orElse(null);
        //SpotsDetails spotsDetails = byId.get();
        return spotsDetails;
    }

    @Override
    public List<SpotsDetails> selectAll() {
        List<SpotsDetails> all = spotsDetailsRepository.findAll();
        return all;
    }

    @Override
    public SpotsDetails queryByDetails(String id) {
        SpotsDetails spotsDetails=spotsDetailsRepository.queryBySpotsId(id);
        return spotsDetails;
    }


}
